Skip to content

Add classify edge-case and error-path test coverage#3417

Merged
brendancol merged 2 commits into
mainfrom
deep-sweep-test-coverage-classify-2026-06-20
Jun 20, 2026
Merged

Add classify edge-case and error-path test coverage#3417
brendancol merged 2 commits into
mainfrom
deep-sweep-test-coverage-classify-2026-06-20

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

What

Test-only additions for xrspatial/classify.py. The source is untouched.

A deep-sweep test-coverage pass found the backend matrix was already complete: all ten public classifiers (binary, reclassify, quantile, natural_breaks, equal_interval, std_mean, head_tail_breaks, percentiles, maximum_breaks, box_plot) run across numpy, dask+numpy, cupy, and dask+cupy with parity assertions. NaN/Inf and metadata preservation are also covered. The gaps were in geometric edge cases and validation error paths.

New tests

Geometric edge cases (Cat 3, MEDIUM):

  • test_classify_single_pixel / test_binary_single_pixel / test_reclassify_single_pixel -- 1x1 raster for every classifier
  • test_classify_nx1_strip / test_classify_1xn_strip -- single-column and single-row strips

Validation error paths (Cat 4, MEDIUM):

  • test_quantile_k_below_min_raises, test_natural_breaks_k_below_min_raises, test_maximum_breaks_k_below_min_raises (k must be >= 2)
  • test_equal_interval_k_below_min_raises (k must be >= 1)

These guards were never exercised; only reclassify's length-mismatch check and the "not enough unique values" fallback were.

Verification

All new tests run and pass on a CUDA host. The full test_classify.py reports 98 passed. Probing the edge shapes live showed they all behave correctly, so no source bug was found and none is filed.

Tests only; classify.py is untouched. The backend matrix was already
complete for all ten classifiers across the four backends, so the gaps
were elsewhere.

New tests:
- 1x1 single-pixel and Nx1 / 1xN strip shapes for every classifier
  (these degenerate shapes were untested)
- the k-below-minimum validation guards (quantile/natural_breaks/
  maximum_breaks require k>=2, equal_interval requires k>=1), which
  previously had no error-path test

All new tests run and pass on a CUDA host; the full file reports 98
passed.

Deep-sweep test-coverage, module: classify.
…age-classify-2026-06-20

# Conflicts:
#	xrspatial/tests/test_classify.py
@brendancol brendancol merged commit 1482589 into main Jun 20, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant